package pers.mor.tomcat.http;

import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import java.util.*;

public class StandardServletConfig implements ServletConfig {

    private ServletContext servletContext;
    private Map<String, String> initParameters;
    private String servletName;

    public StandardServletConfig(ServletContext servletContext, Map<String, String> initParameters, String servletName) {
        this.servletContext = servletContext;
        this.initParameters = initParameters;
        this.servletName = servletName;
        if (this.initParameters == null) {
            this.initParameters = new HashMap<>();
        }
    }

    @Override
    public String getServletName() {
        return this.servletName;
    }

    @Override
    public ServletContext getServletContext() {
        return this.servletContext;
    }

    @Override
    public String getInitParameter(String s) {
        return this.initParameters.get(s);
    }

    @Override
    public Enumeration<String> getInitParameterNames() {
        Set<String> set = this.initParameters.keySet();
        return Collections.enumeration(set);
    }
}
